package com.demo.controller;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.demo.dto.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Api(tags = "测试控制器")
@RequestMapping(value = "/hello")
public class HelloController {

    @GetMapping(value = "/hellotest")
    @ApiOperation(value = "测试方法")
    public String hello() {
        return "this is hello OK";
    }

    @GetMapping(value = "/getIndex")
    public String index() {
        return "Hello is Ok 这是构建的2.0版本-这是更新之后的版本";
    }

    @GetMapping(value = "/getInfos")
    public String getInfos(@RequestBody(required = false) User user) {
        JSONObject jsonObject= JSONUtil.parseObj(user,false);
        String string=jsonObject.toStringPretty();
        System.out.println(string);
        return string;
    }
}
